//
//  ChatController.m
//  weixin
//
//  Created by zhiwei on 16/1/11.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "ChatController.h"

#define ScreenW [UIScreen mainScreen].bounds.size.width
#define ScreenH [UIScreen mainScreen].bounds.size.height
#define PopViewW 100
#define PopViewH 200
#define Margin   10

@interface ChatController ()

@property (nonatomic,weak)UIView *coverView;
@property (nonatomic,weak)UIView *popView;

@end

@implementation ChatController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];

    
    
    //设置barButtonItem
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(rightBarbutttonClick)];
    
    self.navigationItem.rightBarButtonItem = rightItem;
}


-(void)rightBarbutttonClick{
    
    //添加蒙板
    UIView *coverView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    coverView.backgroundColor = [UIColor whiteColor];
    coverView.alpha = 0.02;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
    [coverView addGestureRecognizer:tap];
    [self.tabBarController.view addSubview:coverView];
    self.coverView = coverView;
    
    //添加气泡view
    UIView *popView = [[UIView alloc] init];
    popView.backgroundColor = [UIColor blackColor];
    //气泡X值
    CGFloat popViewX = ScreenW - PopViewW - Margin;
    //设置frame
    popView.frame = CGRectMake(popViewX, Margin+64, PopViewW, PopViewH);
    [self.tabBarController.view addSubview:popView];
    self.popView = popView;
    
    //添加气泡上的button
    UIButton *popBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    popBtn.backgroundColor = [UIColor redColor];
    popBtn.frame = CGRectMake(10, 50, 80, 10);
    [popBtn addTarget:self action:@selector(tapClick) forControlEvents:UIControlEventTouchUpInside];
    [popView addSubview:popBtn];
    
    
}


-(void)tapClick{
    
    [self.coverView removeFromSuperview];
    [self.popView removeFromSuperview];
}



@end
